package com.ay272.sshupdate.config;

import com.sun.org.apache.xpath.internal.operations.Mult;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartRequest;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsFileUploadSupport;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

/**
 * 等同与spring 没mvc的xml

 * Created by java on 2016/5/24.
 */
@Configuration
@EnableWebMvc

@ComponentScan(basePackages ="com.ay272.sshupdate",includeFilters ={@ComponentScan.Filter(value ={Controller.class})},useDefaultFilters = false)
public class WebConfig extends WebMvcConfigurerAdapter {
    /* web视图解决方案*/
    @Bean
    public InternalResourceViewResolver internalResourceViewResolver(){
        InternalResourceViewResolver bean = new InternalResourceViewResolver();
        bean.setViewClass(JstlView.class);
        bean.setPrefix("/WEB-INF/jsp/");
        bean.setSuffix(".jsp");
       //bean.setOrder(1);
        return bean;
    }
    @Bean
    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(){
         MappingJackson2HttpMessageConverter bean = new MappingJackson2HttpMessageConverter();
         return bean;
    }
    @Bean
    public MultipartResolver multipartResolver(){
        CommonsMultipartResolver bean = new CommonsMultipartResolver();
        return bean;
    }
}
